home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / wksfrmt.arc / WKS-FRMT.TXT
Encoding:
Text File  |  1985-10-29  |  36.0 KB  |  1,038 lines

  1.                            WORKSHEET FILE FORMAT
  2.                                  FROM LOTUS
  3.  
  4.                       INTRODUCTION AND QUICK REFERENCE
  5.  
  6.               Copyright(c) 1984, Lotus Development Corporation
  7.                               161 First Street
  8.                        Cambridge, Massachusetts 02142
  9.                                (617) 492-7171
  10.                      Electronic Edition, December, 1984
  11.                             All Rights Reserved
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. PREFACE
  68.  
  69. Lotus Development Corporation's 1-2-3(TM) and Symphony(TM) perform user
  70. selected operations upon a data matrix that is termed a "worksheet".
  71.  
  72. Worksheet files are such matrices stored on disk.
  73.  
  74. A worksheet file is an unbroken sequence of binary coded records defining a
  75. single worksheet.
  76.  
  77. Both 1-2-3 and Symphony accept externally created data files if the files
  78. are in the worksheet file format.  Other programs can decode and process
  79. worksheet files created by 1-2-3 or Symphony.
  80.  
  81. The following document provides information required to create or access a
  82. worksheet file by describing the records used to create a worksheet file.
  83. It is assumed that the reader is familiar with Lotus products and has ready
  84. access to 1-2-3 or Symphony documentation.
  85.  
  86. Note that the worksheet files for 1-2-3 and Symphony are similar, but not
  87. necessarily interchangeable.  1-2-3 and Symphony share some record types,
  88. but also have record types unique to that product.  Symphony can read 1-2-3
  89. records, but 1-2-3 cannot read Symphony records.
  90.  
  91. The information contained in this document has been released into the
  92. public domain and is not considered to be confidential or proprietary
  93. although still the copyright and property of Lotus Development Corporation.
  94. All efforts have been made to ensure that this information is clear and
  95. useful since Lotus will not be providing customer assistance with this
  96. booklet.  Lotus will, however, incorporate any necessary corrections if
  97. they are reported in writing to:
  98.  
  99.                        Lotus Development Corporation
  100.                        Worksheet File Format
  101.                        161 First Street
  102.                        Cambridge, MA 02142
  103.  
  104.  
  105. WORKSHEET FILE FORMAT
  106.  
  107. Worksheet files are organized as an unbroken sequence of variable length
  108. binary records.  Each record consists of a 4-byte header followed by the
  109. record body. The header defines the record's type and length, as the
  110. example below shows.
  111.  
  112. The header's composition is as follows:
  113.  
  114.  
  115.  
  116. Byte Number               Byte Description
  117. 0,1                       Record type code
  118. 2,3                       Record body length (bytes)
  119.  
  120.  
  121. Example: Record Header
  122.  
  123.                               Record Header
  124.  
  125.                           Record         Record
  126.                            Type          Length
  127.  
  128.          Byte Number      0    1         2    3
  129.             Hex Code     1C   00        20   00
  130.   Decimal Equivalent       28             32
  131.  
  132.  
  133. The record body can be of many different types; most have predetermined
  134. length, but some vary in length.
  135.  
  136. The record type code is 28.
  137.  
  138. In a hex dump of the file, the record type appears as 1C 00h, noting that
  139. the 8086/88 stores the most significant byte of word in the higher memory
  140. address.
  141.  
  142. The record length is 32 bytes.
  143. In a hex dump of the file, the record length appears as 20 00h.
  144.  
  145.  
  146. Record types with Column/Row Coordinates
  147.  
  148. Some record types contain column/row coordinates to identify a cell, or one
  149. of the two points that define a range.  Numbering starts at zero in the
  150. upper left corner of the worksheet.
  151. For example:
  152.  
  153.                             Cell A1 = column 0, row 0
  154.  
  155.  
  156.  
  157.  
  158.  
  159. SUMMARY OF RECORD TYPES
  160.  
  161. This section describes the different record types found in 1-2-3 and
  162. Symphony.
  163.  
  164. There are to Quick Reference tables ordered by Opcode and by Product,
  165. followed by a detailed reference section ordered by Opcode.  In the
  166. reference section, there are examples for the more commonly used records.
  167.  
  168. It is assumed that the reader is familiar with 1-2-3 or Symphony and has
  169. access to Lotus' documentation.
  170.  
  171. Quick Reference by Opcode
  172.  
  173. Type       Code (hex)        Length (bytes)         Description
  174.  
  175. BOF            0                2                   Beginning of file
  176. EOF            1                0                   End of file
  177. CALCMODE       2                1                   Calculation mode
  178. CALCORDER      3                1                   Calculation order
  179. SPLIT          4                1                   Split window type
  180. SYNC           5                1                   Split window sync
  181. RANGE          6                8                   Active worksheet range
  182. WINDOW1        7                31                  Window 1 record
  183. COLW1          8                3                   Column width,
  184.                                                       window 1
  185. WINTWO         9                31                  Window 2 record
  186. COLW2          A                3                   Column width,
  187.                                                       window 2
  188. NAME           B                24                  Named range
  189. BLANK          C                5                   Blank cell
  190. INTEGER        D                7                   Integer number cell
  191. NUMBER         E                13                  Floating point number
  192. LABEL          F                variable            Label cell
  193. FORMULA        10               variable            Formula cell
  194. TABLE          18               25                  Data table range
  195. ORANGE         19               25                  Query range
  196. PRANGE         1A               8                   Print range
  197. SRANGE         1B               8                   Sort range
  198. FRANGE         1C               8                   Fill range
  199. KRANGE1        1D               9                   Primary sort key range
  200. HRANGE         20               16                  Distribution range
  201. KRANGE2        23               9                   Secondary sort key
  202.                                                       range
  203. PROTEC         24               1                   Global protection
  204. FOOTER         25               242                 Print footer
  205. HEADER         26               242                 Print header
  206. SETUP          27               40                  Print setup
  207. MARGINS        28               10                  Print margins code
  208.  
  209.  
  210.  
  211. Quick Reference by Opcode (continued)
  212.  
  213. Type         code (hex)       Length (bytes)        Description
  214.  
  215. LABELFMT        29                  1               Label alignment
  216. TITLES          2A                  16              Print borders
  217. GRAPH           2D                  437             Current graph settings
  218. NGRAPH          2E                  453             Named graph settings
  219. CALCCOUNT       2F                  1               Iteration count
  220. UNFORMATTED     30                  1               Formatted/unformatted
  221.                                                       print
  222. CURSORW12       31                  1               Cursor location
  223. WINDOW          32                  144             Symphony window
  224.                                                       settings
  225. STRING          33                  variable        Value of string
  226.                                                       formula
  227. PASSWORD        37                  4               File lockout (CHKSUM)
  228. LOCKED          38                  1               Lock flag
  229. QUERY           3C                  127             Symphony query
  230.                                                       settings
  231. QUERYNAME       3D                  16              Query name
  232. PRINT           3E                  679             Symphony print record
  233. PRINTNAME       3F                  16              Print record name
  234. GRAPH2          40                  499             Symphony graph
  235.                                                       record
  236. GRAPHNAME       41                  16              Graph record name
  237. ZOOM            42                  9               Orig coordinates
  238.                                                       expanded window
  239. SYMSPLIT        43                  2               Nos. of split windows
  240. NSROWS          44                  2               Nos. of screen rows
  241. NSCOLS          45                  2               Nos. of screen columns
  242. RULER           46                  25              Named ruler range
  243. NNAME           47                  25              Named sheet range
  244. ACOMM           48                  65              Autoload.comm code
  245. AMACRO          49                  8               Autoexecute macro
  246.                                                       address
  247. PARSE           4A                  16              Query parse
  248.                                                       information
  249.  
  250.  
  251.  
  252.  
  253. Quick Reference by Product: 1-2-3 only
  254.  
  255. Type          Code (hex)         Length (bytes)     Description
  256.  
  257. SPLIT            4                    1             Split window type
  258. SYNC             5                    1             Split window sync
  259. WINDOW 1         7                    31            Window 1 record
  260. WINTWO           9                    31            Window 2 record
  261. COLW2            A                    3             Column width,
  262.                                                       window 2
  263. NAME             B                    24            Named range
  264. QRANGE           19                   25            Query range
  265. PRANGE           1A                   8             Print range
  266. SRANGE           1B                   8             Sort range
  267. KRANGE1          1D                   9             Primary sort key range
  268. KRANGE2          23                   9             Secondary sort key
  269.                                                       range
  270. FOOTER           25                   242           Print footer
  271. HEADER           26                   242           Print header
  272. SETUP            27                   40            Print setup
  273. MARGINS          28                   10            Print margins code
  274. TITLES           2A                   16            Print borders
  275. GRAPH            2D                   437           Current graph settings
  276. NGRAPH           2E                   453           Named graph settings
  277.  
  278.  
  279.  
  280.  
  281. Quick Reference by Product: 1-2-3 and Symphony
  282.  
  283. Type          Code (hex)         Length (bytes)     Description
  284.  
  285. BOF               0                   2             Beginning of file
  286. EOF               1                   0             End of file
  287. CALCMODE          2                   1             Calculation mode
  288. CALCORDER         3                   1             Calculation order
  289. RANGE             6                   8             Active worksheet range
  290. COLW1             8                   3             Column width
  291. BLANK             C                   5             Blank cell
  292. INTEGER           D                   7             Integer number cell
  293. NUMBER            E                   13            Floating point number
  294. LABEL             F                   variable      Label cell
  295. FORMULA           10                  variable      Formula cell
  296. TABLE             18                  25            Data table range
  297. FRANGE            1C                  8             Fill range
  298. HRANGE            20                  16            Distribution range
  299. PROTEC            24                  1             Global protection
  300. LABELFMT          29                  1             Label alignment
  301. CALCCOUNT         2F                  1             Iteration count
  302. UNFORMATTED       30                  1             Formatted/unformatted
  303.                                                       print
  304. CURSORW12         31                  1             Cursor location
  305.  
  306.  
  307.  
  308.  
  309. Quick Reference by Product: Symphony only
  310.  
  311. Type          Code (hex)        Length (bytes)      Description
  312.  
  313. WINDOW           32                 144             Symphony window
  314.                                                       settings
  315. STRING           33                 variable        Value of string
  316.                                                       formula
  317. PASSWORD         37                 4               File lockout (CHKSUM)
  318. LOCKED           38                 1               Lock flag
  319. QUERY            3C                 127             Symphony query
  320.                                                       settings
  321. QUERYNAME        3D                 16              Query name
  322. PRINT            3E                 679             Symphony print record
  323. PRINTNAME        3F                 16              Print record name
  324. GRAPH2           40                 499             Symphony graph
  325.                                                       record
  326. GRAPHNAME        41                 16              Graph rocord name
  327. ZOOM             42                 9               Orig coordinates
  328.                                                       expanded window
  329. SYMSPLIT         43                 2               Nos. of split windows
  330. NSROWS           44                 2               Nos. of screen rows
  331. NSCOLS           45                 2               Nos. of screen columns
  332. RULER            46                 25              Named ruler range
  333. NNAME            47                 25              Named sheet range
  334. ACOMM            48                 65              Autoload. comm code
  335. AMACRO           49                 8               Autoexecute macro
  336.                                                       address
  337. PARSE            4A                 16              Query parse
  338.                                                       information
  339.  
  340.  
  341.  
  342.  
  343.  
  344.                            WORKSHEET FILE FORMAT
  345.                                  FROM LOTUS
  346.  
  347.                      APPENDIX A - CELL FORMAT ENCODING
  348.  
  349.               Copyright(c) 1984, Lotus Development Corporation
  350.                               161 First Street
  351.                        Cambridge, Massachusetts 02142
  352.                                (617) 492-7171
  353.                      Electronic Edition, December, 1984
  354.                             All Rights Reserved
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.                      APPENDIX A:  Cell Format Encoding
  411.  
  412.  
  413. The first byte of a content-related record contains a cell format code.
  414.  
  415. Format is determined at the bit level.
  416.  
  417.  
  418. Table 8   Cell Format Encoding
  419.  
  420. Bit number     Description               Code             Meaning
  421. 7              protection                1                protected
  422.                                          0                unprotected
  423.  
  424. 4,5,6          format type               0                fixed
  425.                                          1                scientific
  426.                                                             notation
  427.                                          2                currency
  428.                                          3                percent
  429.                                          4                comma
  430.                                          5                unused
  431.                                          6                unused
  432.                                          7                special
  433. 0,1,2,3        number of decimal         0-15
  434.                 places decoded
  435.                 (if format type = 0-6)
  436.  
  437.                special format type       0                +/-
  438.                (if format type = 7)      1                general
  439.                                          2                day-month-year
  440.                                          3                day-month
  441.                                          4                month-year
  442.                                          5                text
  443.                (Symphony only)           6                hidden
  444.                (Symphony only)           7                date;hour-min-sec
  445.                (Symphony only)           8                date;hour-min
  446.                (Symphony only)           9                date;intnt'l1
  447.                (Symphony only)           10               date;intnt'l1
  448.                (Symphony only)           11               time;intnt'l1
  449.                (Symphony only)           12               time;intnt'l2
  450.                                          13-14            unused
  451.                                          15               default
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459. EXAMPLE
  460.  
  461. Currency format, two decimal places, unprotected cell
  462.  
  463.  
  464. Bit Number    7   6   5   4   3   2   1   0
  465. Binary Code   0   0   1   0   0   0   1   0
  466.                   ---------
  467.                  Format Type ---------------
  468.               Protection     Number of Decimal Places
  469.                                  or Special Format
  470.  
  471. The byte number is 0.
  472. The hex code is 22.
  473.  
  474.  
  475. Example
  476.  
  477. Special format, month-year, protected cell
  478.  
  479.  
  480. Bit Number     7   6   5   4   3   2   1   0
  481. Binary Code    1   1   1   1   0   1   0   0
  482.                    ---------
  483.                   Format Type  -------------
  484.                 Protection    Number of Decimal Places
  485.                                  or Special Format
  486.  
  487.  
  488. The byte number is 0.
  489. The hex code is F4.
  490.  
  491.  
  492.  
  493.  
  494.  
  495.                            WORKSHEET FILE FORMAT
  496.                                  FROM LOTUS
  497.  
  498.                      APPENDIX B - THE FORMULA COMPILER
  499.  
  500.               Copyright(c) 1984, Lotus Development Corporation
  501.                               161 First Street
  502.                        Cambridge, Massachusetts 02142
  503.                                (617) 492-7171
  504.                      Electronic Edition, December, 1984
  505.                             All Rights Reserved
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.                      APPENDIX B:  The Formula Compiler
  563.  
  564. This appendix describes the internal workings of the formula compiler.  The
  565. compiler transforms an ASCII string of characters representing a formula to
  566. its Reverse Polish code.  The basic algorithm utilizes and SR parser (SR =
  567. shift and reduce).  The aim of the parser is to apply a set of reduction
  568. rules which embody the syntax of the compiler to an input string.  Formula
  569. code is compiled to a temporary buffer.
  570.  
  571. Lexicon Analysis
  572.  
  573. A lexical analyzer breaks up the input string into lexical units called
  574. tokens.  A token is a substring of the original input string operand,
  575. operator, or special symbol (such as comma, parentheses, etc.) In addition,
  576. the lexical analyser supplies two special tokens, "beginning of formula"
  577. (boform) and "end of formula" (eoform), to facilitate the compilation
  578. process.  The lexical analyzer identifies and processes literals (both
  579. number and string), cell and range references, operators, and function
  580. calls.  It assigns a unique code to each distinct operator, function, or
  581. type of operand.
  582.  
  583. A function with no arguments is treated like a number.
  584.  
  585. Syntax Analysis
  586.  
  587. The syntactical analysis of a formula is accomplished by processing a list
  588. of tokens in left-to-right order.  A stack called the syntax is also used
  589. during the syntactical scan.  The basic algorithm is as follows:
  590.  
  591. Repeat the following steps:
  592.  
  593. 1) Get the next token
  594.  
  595. 2) If the token is a literal or cell reference:
  596.       a) Push the number code on the syntax stack
  597.       b) Push the number code on the syntax stack
  598.  
  599. 3) If the token is a range reference:
  600.       a) Compile code to push the range reference
  601.       b) Push the range code on the syntax stack
  602.  
  603. 4) Otherwise push the token code for the token on the syntax stack.
  604.  
  605. For each syntax rule, if the pattern on the top of the  syntax matches the
  606. rule pattern take the action associated with the rule and start scanning
  607. from the beginning for any additional rules which may apply.
  608.  
  609. When a token code is pushed on the syntax stack, an additional word of
  610. zeros is also pushed on the stack.  This is used when compiling function
  611. calls to hold the function's argument count.
  612.  
  613.  
  614.  
  615.  
  616.  
  617. Rule Matching
  618.  
  619. A relatively small number of rules are used to process formulas of arbitrary
  620. complexity.  If a rule matches the top of the syntax stack, then the
  621. compiler takes a specific action and rule scanning starts again with the
  622. first rule.  Each rule matches certain patterns on the syntax stack.  A
  623. typical rule might be: if the top of the stack is the token for right
  624. parenthesis, and the next-to-top is a number, and the second form the top
  625. is a left parenthesis, then pop the top three items from the syntax stack
  626. and push the number on the syntax stack.
  627.  
  628. This rule can be more succinctly represented as:
  629.  
  630.                        Stack
  631.  
  632.          Before                      After                 Action
  633.          )
  634.          number
  635.          (                           number                none
  636.  
  637.  
  638.  
  639. The Rules
  640.  
  641.  
  642. The following are the syntax rules used to process formulas.  Note that the
  643. order of the rules is important.  The rules for compilation of operators
  644. used additional tables which assign a precedence number and opcode to each
  645. legal unary and binary operator.  Thus, for example, there is a single
  646. token code for minus sign (-), but there are two opcodes one for unary
  647. minus and one for binary minus.  In addition, these two operators, while
  648. lexically identical, also have different precedence.  In general, operators
  649. of higher precedence will be performed before operators of lower precedence
  650. are performed left-to-right.  All special operators (boform, eoform,
  651. parentheses, comma, etc.) are implicitly assigned a precedence of zero.
  652.  
  653. Rule 1  Termination test
  654.  
  655.                  Stack
  656.  
  657.         Before           After       Action
  658.         eoform                       Output a return code to compile buffer
  659.         number                       Return, indicating successful compile
  660.         boform
  661.  
  662. Rule 2  Function argument processing
  663.  
  664.                 Stack
  665.         Before          After       Action
  666.         '                           Error if range argument illegal for
  667.         number or range             function.
  668.         (               (           Increment argument count on stack
  669.         function        function
  670.  
  671. Rule 3  Process final function argument
  672.  
  673.                 Stack
  674.         Before         After        Action
  675.         )                           Error if range argument illegal for
  676.         number or range             function.
  677.         (                           Increment argument count on stack
  678.         function       number       Compile function opcode
  679.                                     If list function, compile argument
  680.                                     count; otherwise error is wrong
  681.                                     argument count.
  682.  
  683.  
  684.  
  685.  
  686. Rule 4  Parenthesis removal
  687.  
  688.                Stack
  689.        Before         After        Action
  690.        )                           Compile parenthesis opcode
  691.        number
  692.        (              number
  693.        operator       operator
  694.  
  695.  
  696.  
  697. Rule 5  Binary operators
  698.  
  699.               Stack
  700.        Before         After        Action
  701.        op2                         If binary op<binary op, rule does
  702.        number                      not match.  Otherwise, compile opcode
  703.        op1            op2          for operator op1.
  704.  
  705.  
  706. Rule 6  Unary operators
  707.  
  708.               Stack
  709.        Before      After           Action
  710.        op2                         I unary op<binary op, rule does
  711.        number      op2             not match.  Otherwise, compile opcode.
  712.        op1         number          for operator op 1.
  713.  
  714.  
  715. Rule 7  Error detection
  716.  
  717.              Stack
  718.       Before       After          Action
  719.       eoform                      Return indicating unsuccessful compile
  720.  
  721.  
  722.  
  723.  
  724.  
  725. Table 9   Operator Precedence Table
  726.  
  727. Operator              Unary Precedence       Binary Precedence
  728. +                             6                      4
  729. -                             6                      4
  730. *                            na                      5
  731. /                            na                      7
  732. ^                            na                      3
  733. =                            na                      3
  734. < >                          na                      3
  735. < =                          na                      3
  736. > =                          na                      3
  737. <                            na                      3
  738. >                            na                      3
  739. #and#                        na                      1
  740. #or#                         na                      1
  741. #not#                        2                      na
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753. Example:
  754.  
  755. Using the above rules, we can now see how a particular formula is
  756. compiled.  Let us consider the following formula:
  757.  
  758.                  3+5*6
  759.  
  760. This is broken up by the lexical analyzer into seven tokens.
  761.  
  762.                  boform
  763.                  3
  764.                  +
  765.                  5
  766.                  *
  767.                  6
  768.                  eoform
  769.  
  770. The syntax scans proceed as follows until a matching rule is found:
  771.  
  772. Stack
  773.  
  774. boform           number         +            number
  775.                  boform         number       +
  776.                                 boform       number
  777.                                              boform
  778.  
  779. Compile buffer
  780.  
  781.                  push 3         push 3       push 3
  782.                                              push 5
  783.  
  784. At this point, rule 5 is invoked, but since the precedence of boform is
  785. zero, no action is taken.
  786.  
  787. Stack
  788.  
  789. *                number
  790. number           *
  791. +                number
  792. number           +
  793. boform           number
  794.                  boform
  795.  
  796. Compile buffer
  797.  
  798. push 3           push 3
  799. push 5           push 5
  800.                  push 6
  801.  
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808. At this  point, since the binary precedence of + is lower than the binary
  809. precedence of *, rule 5 does apply, and the opcode for * is compiled.  The
  810. stack is reduced by replacing number * number by number and scan is made,
  811. but no further rule applies.
  812.  
  813.  
  814. Stack
  815.  
  816. number          eoform
  817. +               number
  818. number          +
  819. boform          number
  820.                 boform
  821.  
  822. Compile buffer
  823.  
  824. push 3          push 3
  825. push 5          push 5
  826. push 6          push 6
  827.  
  828.  
  829.  
  830. Rule 5 applies again, and the opcode for + is compiled, reducing the stack
  831. to boform, number, eoform.  Rescanning finds a match on rule 1 which
  832. compiles a return opcode and terminates.  The final compiled code is thus:
  833.  
  834. push 3
  835. push 5
  836. push 6
  837. *
  838. +
  839. return
  840.  
  841. A Note on the Decompiler
  842.  
  843. The algorithm for the formula decompiler was taken verbatim from:
  844.  
  845. Writing Interactive Compilers and Interpreters, P.J. Brown, John Wiley and
  846. Sons, 1979.  See chapter 6.2.  The algorithm itself is described on pages
  847. 216 and 217.
  848.  
  849. This algorithm is also described in the following article.
  850.  
  851. More on the Re-creation of Source Code from Reverse Polish, P.J. Brown,
  852. Software Practice and Experience, Vol 7, 545-551 (1977).
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863. WORKSHEET COLUMN DESIGNATORS
  864.  
  865. Most records within the 1-2-3 Condensed Worksheet format are specified
  866. with column/row designators (for example, column 0, row 0 equals A1).  When
  867. determining the column designator, the table below will help make
  868. conversion easier.
  869.  
  870.  
  871. Column   Hex   Dec        Column   Hex   Dec        Column   Hex   Dec
  872.   A       0     1           BA     34     52          DA     68    104
  873.   B       1     1           BB     35     53          DB     69    105
  874.   C       2     2           BC     36     54          DC     6A    106
  875.   D       3     3           BD     37     55          DD     6B    107
  876.   E       4     4           BE     38     56          DE     6C    108
  877.   F       5     5           BF     39     57          DF     6D    109
  878.   G       6     6           BG     3A     58          DG     6E    110
  879.   H       7     7           BH     3B     59          DH     6F    111
  880.   I       8     8           BI     3C     60          DI     70    112
  881.   J       9     9           BJ     3D     61          DJ     71    113
  882.   K       A    10           BK     3E     62          DK     72    114
  883.   L       B    11           BL     3F     63          DL     73    115
  884.   M       C    12           BM     40     64          DM     74    116
  885.   N       D    13           BN     41     65          DN     75    117
  886.   O       E    14           BO     42     66          DO     76    118
  887.   P       F    15           BP     43     67          DP     77    119
  888.   Q      10    16           BQ     44     68          DQ     78    120
  889.   R      11    17           BR     45     69          DR     79    121
  890.   S      12    18           BS     46     70          DS     7A    122
  891.   T      13    19           BT     47     71          DT     7B    123
  892.   U      14    20           BU     48     72          DU     7C    124
  893.   V      15    21           BV     49     73          DV     7D    125
  894.   W      16    22           BW     4A     74          DW     7E    126
  895.   X      17    23           BX     4B     75          DX     7F    127
  896.   Y      18    24           BY     4C     76          DY     80    128
  897.   Z      19    25           BZ     4D     77          DZ     81    129
  898.  AA      1A    26           CA     4E     78          EA     82    130
  899.  AB      1B    27           CB     4F     79          EB     83    131
  900.  AC      1C    28           CC     50     80          EC     84    132
  901.  AD      1D    29           CD     51     81          ED     85    133
  902.  AE      1E    30           CE     52     82          EE     86    134
  903.  AF      1F    31           CF     53     83          EF     87    135
  904.  AG      20    32           CG     54     84          EG     88    136
  905.  AH      21    33           CH     55     85          EH     89    137
  906.  AI      22    34           CI     56     86          EI     8A    138
  907.  AJ      23    35           CJ     57     87          EJ     8B    139
  908.  AK      24    36           CK     58     88          EK     8C    140
  909.  AL      25    37           CL     59     89          EL     8D    141
  910.  AM      26    38           CM     5A     90          EM     8E    142
  911.  AN      27    39           CN     5B     91          EN     8F    143
  912.  AO      28    40           CO     5C     92          EO     90    144
  913.  AP      29    41           CP     5D     93          EP     91    145
  914.  AQ      2A    42           CQ     5E     94          EQ     92    146
  915.  AR      2B    43           CR     5F     95          ER     93    147
  916.  AS      2C    44           CS     60     96          ES     94    148
  917.  AT      2D    45           CT     61     97          ET     95    149
  918.  AU      2E    46           CU     62     98          EU     96    150
  919.  AV      2F    47           CV     63     99          EV     97    151
  920.  AW      30    48           CW     64    100          EW     98    152
  921.  AX      31    49           CX     65    101          EX     99    153
  922.  AY      32    50           CY     66    102          EY     9A    154
  923.  AZ      33    51           CZ     67    103          EZ     9B    155
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932. (CONTINUED)
  933.  
  934.  
  935.  
  936.  
  937.               Column   Hex    Dec         Column    Hex    Dec
  938.  
  939.                 FA     9C     156           HA      DO     208
  940.                 FB     9D     157           HB      D1     209
  941.                 FC     9E     158           HC      D2     210
  942.                 FD     9F     159           HD      D3     211
  943.                 FE     AO     160           HE      D4     212
  944.                 FF     A1     161           HF      D5     213
  945.                 FG     A2     162           HG      D6     214
  946.                 FH     A3     163           HH      D7     215
  947.                 FI     A4     164           HI      D8     216
  948.                 FJ     A5     165           HJ      D9     217
  949.                 FK     A6     166           HK      DA     218
  950.                 FL     A7     167           HL      DB     219
  951.                 FM     A8     168           HM      DC     220
  952.                 FN     A9     169           HN      DD     221
  953.                 FO     AA     170           HO      DE     222
  954.                 FP     AB     171           HP      DF     223
  955.                 FQ     AC     172           HQ      EO     224
  956.                 FR     AD     173           HR      E1     225
  957.                 FS     AE     174           HS      E2     226
  958.                 FT     AF     175           HT      E3     227
  959.                 FU     BO     176           HU      E4     228
  960.                 FV     B1     177           HV      E5     229
  961.                 FW     B2     178           HW      E6     230
  962.                 FX     B3     179           HX      E7     231
  963.                 FY     B4     180           HY      E8     232
  964.                 FZ     B5     181           HZ      E9     233
  965.                 GA     B6     182           IA      EA     234
  966.                 GB     B7     183           IB      EB     235
  967.                 GC     B8     184           IC      EC     236
  968.                 GD     B9     185           ID      ED     237
  969.                 GE     BA     186           IE      EE     238
  970.                 GF     BB     187           IF      EF     239
  971.                 GG     BC     188           IG      FO     240
  972.                 GH     BD     189           IH      F1     241
  973.                 GI     BE     190           II      F2     242
  974.                 GJ     BF     191           IJ      F3     243
  975.                 GK     CO     192           IK      F4     244
  976.                 GL     C1     193           IL      F5     245
  977.                 GM     C2     195           IM      F6     246
  978.                 GN     C3     195           IN      F7     247
  979.                 GO     C4     196           IO      F8     248
  980.                 GP     C5     197           IP      F9     249
  981.                 GQ     C6     198           IQ      FA     250
  982.                 GR     C7     199           IR      FB     251
  983.                 GS     C8     200           IS      FC     252
  984.                 GT     C9     201           IT      FD     253
  985.                 GU     CA     202           IU      FE     254
  986.                 GV     CB     203           IV      FF     255
  987.                 GW     CC     204
  988.                 GX     CD     205
  989.                 GY     CE     206
  990.                 GZ     CF     207
  991.  
  992.  
  993.  
  994.  
  995. ANALYSIS OF 1-2-3  WORKSHEET FILE
  996.  
  997. The worksheet shown below was created in 1-2-3 and saved to disk.
  998.  
  999.  
  1000.  
  1001.                                              Key:
  1002.  
  1003.                                              A2..A5 Named Range (code 11)
  1004.          EXAMPLE                                 A2: Label (code 15)
  1005.             100                                  A3: Integer (code 13)
  1006.            12.5                                  A4: Number (code 14)
  1007.            87.5                                  A5: Formula (+A3-A4)
  1008.                                                      (code 16)
  1009.  
  1010.  
  1011. The example shown below is a partial hex dump of this worksheet file.  By
  1012. reading each record header, you can determine the type of record you are
  1013. encountering.  The record header will also tell you the length of that
  1014. follows the header.  By analyzing the record header, you can read the
  1015. records you want and skip unrelated records.
  1016.  
  1017.  
  1018.    362B:0100                           06 00 08 00 00 00 00 00 00 00
  1019.    362B:0110        04 00 2F 00 01 00  01 02 00 01 00 FF 03 00 01 00
  1020.    362B:0120        00 04 00 01 00 00  05 00 01 00 FF 07 00 1F 00 00
  1021.    362B:0130        00 01 00 71 00 09  00 08 00 14 00 00 00 00 00 00
  1022.    362B:0140        00 00 00 00 00 00  00 04 00 04 00 48 00 00 0B 00
  1023.    362B:0150        18 00 54 45 53 54  00 00 00 00 00 00 00 00 00 00
  1024.    362B:0160        00 00 00 00 01 00  00 00 04 00 18 00 19 00 00 FF
  1025.    362B:0170        FF 00 00 FF FF 00  00 FF FF 00 00 FF FF 00 00 FF
  1026.    362B:0180
  1027.  
  1028.  
  1029.    362B:05C0
  1030.    362B:05D0        00 00 00 00 00 00  00 00 00 00 00 00 00 00 00 00
  1031.    362B:05E0        00 00 00 00 00 00  00 00 00 00 00 00 00 00 00 00
  1032.    362B:05F0        00 00 00 00 71 71  01 00 0F 00 0E 00 FF 00 00 01
  1033.    362B:0600        00 27 45 58 41 4D  50 4C 45 00 0D 00 07 00 FF 00
  1034.    362B:0610        00 02 00 64 00
  1035.    362B:0620                           10 00 1B 00 FF 00 00 04 00 00
  1036.    362B:0630        00 00 00 00 E0 55  40 0C 00 01 00 80 FE BF 01 00
  1037.    362B:0640        80 FF BF 0A 03
  1038.